home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fritz: All Fritz
/
All Fritz.zip
/
All Fritz
/
FILES
/
PROGNG_C
/
TCHK060.LZH
/
TCHK.DOC
< prev
next >
Wrap
Text File
|
1988-01-15
|
172KB
|
7,458 lines
TCHK - a Turbo C library
Version 0.60
Documentation for TCHK
by
Howard Kapustein
Howard Kapustein
1695 Barbara Lane
East Meadow, NY 11554
(516) 481-9612
(c) Copyright 1987, All rights reserved
Page 1
Table of Contents
COPYRIGHT AND DISCLAIMER .......................................... 3
TRADEMARKS ........................................................ 3
LICENSE ........................................................... 3
BACKGROUND ........................................................ 4
FILES ............................................................. 4
IN THE BEGINNING.. ................................................ 5
FEATURES .......................................................... 5
CREDIT ............................................................ 5
FUNCTIONS ......................................................... 6
atrim - trims leading and trailing blanks .................... 9
ltrim - trims leading blanks ................................. 9
rtrim - trims trailing blanks ................................ 9
box - draw a box ............................................. 10
Cal... - family of Calendar date conversion .................. 11
clear - clears a portion of the screen ....................... 12
clear_typeahead - clear typeahead buffer ..................... 13
cls - clear screen ........................................... 14
cursor_blink - set speed of cursor blink ..................... 15
cursor_flip - toggle the cursor type ......................... 16
cursor_off - turn the cursor off ............................. 17
cursor_on - turn the cursor on ............................... 18
dayofweek - find the day of the week ......................... 19
dayofyear - calculate the day of the year .................... 20
daysleft - calculate the days left in the year ............... 21
ddatetolong - convert a date to long string .................. 22
ddatetoshort - convert a date to short string ................ 23
ddatetostr - convert a date to abbrev. string ................ 24
delay - wait for a time delay ................................ 25
DESQfreeCPU - give up CPU time ............................... 26
DESQversion - DESQview/Topview/Taskview version .............. 27
diffddate - calculate the difference in 2 dates .............. 28
disktype - disk drive type ................................... 29
DoubleDOSfreeCPU - give up CPU time under .................... 30
DoubleDOSTaskSwitch - set Double DOS task .................... 31
EMMversion - version of Expanded Memory Manager .............. 32
Extendedtotal - total Extended memory installed .............. 33
fulltoddate - convert a full date to struct .................. 34
shorttoddate - convert a short date to struct ................ 34
getc_match - get specific input, case independent ........... 35
getk_match - get specific input, case dependent .............. 35
getddate - inputs a date from the keyboard ................... 36
getdouble - inputs a double from the keyboard ................ 37
Page 2
getfname - get a filename from the keyboard .................. 38
getget - get a string from the keyboard w/editing ............ 39
getint - inputs an integer from the keyboard ................. 40
getk - get a key ............................................. 41
getlogical - get Yes/No ...................................... 42
getreal - inputs a real from the keyboard .................... 43
getstr - input a string from the keyboard .................... 44
getyn - get Yes/No ........................................... 46
gotoxy - move cursor to coordinates (x,y) .................... 47
Greg... - family of Gregorian date conversion ................ 48
horiz_line - draw a horizontal line .......................... 49
inkey - get a key ............................................ 50
intlen - calculate length of integer in a string ............. 51
isBREAKon - check Ctrl-BREAK flag ............................ 52
isCGA - is Color Graphics adapter installed .................. 53
isEGA - is Enhanced Graphics adapter installed ............... 53
isHerc - is Hercules Graphics adapter installed .............. 53
isMDA - is Monochrome adapter installed ...................... 53
isDoubleDOS - is Double DOS active ........................... 54
isEMSavail - is EMS available ................................ 55
isExtended - is Extended memory installed .................... 56
isleapyear - is a year a leap year ........................... 57
isNetwork - is a network installed ........................... 58
isVERIFYon - check VERIFY flag ............................... 59
Jul... - family of Julian date conversion .................... 60
leftstr - return the left portion of string .................. 61
midstr - return a piece of a string .......................... 61
rightstr - return the right portion of a string .............. 61
lotus_setup - creates info for menu_lotus() .................. 63
memory_strategy - get/set memory alloc strategy .............. 64
menu_lotus - Lotus style menu ................................ 65
monthexpand - convert a month abbrev to its name ............. 67
putk - put a character w/attribute on the screen ............. 68
putsay - put a string with attribute on the screen ........... 69
putstr - put a string with attribute on the screen ........... 70
read_cursor - reads cursor information ....................... 71
read_mode - find screen width, mode and page ................. 72
reboot - reboots the machine ................................. 73
restore_box - restore a part of the screen ................... 74
restore_screen - restore screen .............................. 75
ROM_date - gets the ROM id date .............................. 76
ROM_id - gets the ROM id byte ................................ 77
save_box - save a part of the screen ......................... 78
save_screen - save screen .................................... 79
scrbuff - calculate size of screen buffer .................... 80
scroll_down - scroll window down ............................. 81
scroll_up - scroll window up ................................. 82
setBREAK - set Ctrl-BREAK flag ............................... 83
set_color - set the default attribute (color) ................ 84
set_cursor - sets cursor scan lines .......................... 85
set_handles - set handle count ............................... 86
setVERIFY - set VERIFY flag .................................. 87
set_mode - set the video mode ................................ 88
Page 3
strcomma - convert a string to xx,xxx,xxx format ............. 89
strdel - delete part of a string ............................. 90
strins - insert one string into another ...................... 91
strrep - replicate a char .................................... 92
strshleft - shift string left ................................ 93
strshright - shift string right .............................. 93
strtoddate - convert a date string to a structure ............ 94
strtodol - converts a string to dollar format ................ 95
strtotime - convert a string to a time structure ............. 96
timetostr - convert time structure to a string ............... 97
valid_date - check if a date is valid ........................ 98
vert_line - draw a vertical line ............................. 99
wherex - X-coordinate of cursor ............................. 100
wherey - y-coordinate of cursor ............................. 101
#DEFINES .......................................................... 102
Datehk.h ..................................................... 102
Filehk.h ..................................................... 102
Howard.h ..................................................... 102
Ibm.h ........................................................ 103
Math.h ....................................................... 104
Video.h ...................................................... 104
VARIABLE TYPES .................................................... 105
GLOBAL VARIABLES .................................................. 105
Datehk variables: ............................................ 105
Keyboard variables: .......................................... 105
Video variables: ............................................. 105
REVISION HISTORY .................................................. 106
FUTURE ENHANCEMENTS ............................................... 107
APPENDIX A - DATE FORMATS ......................................... 108
INDEX ............................................................. 109
Page 3
COPYRIGHT AND DISCLAIMER
This library and documentation are Copyrighted (C) 1987 by Howard
Kapustein, All Rights Reserved.
Use of this library acknowledges this disclaimer of warranty:
"This library is supplied as-is. The author disclaims all
warranties, expressed or implied, including, without limitation,
the warranties of merchantability and of fitness of this library
for any purpose. The author assumes no liability for damages
direct or consequential, which may result from the use of this
library."
TRADEMARKS
Macintosh is a registered trademark of Apple Incorporated.
dBase III+ is a registered trademark of Ashton-Tate Incorporated.
Turbo C is a registered trademark of Borland International.
Symphony is a registered trademark of Lotus Corp.
LICENSE
TCHK is distributed as "shareware", as outlined below.
Nonregistered users are granted a limited license to use this
library for personal, private ends, and may develop software
using the functions contained herein, but may not distribute,
sell nor otherwise release or profit from any product made with
TCHK. Users may become REGISTERED owners for a small pittance of
$15. Registering has the following benefits:
Registered owners will receive TCHK compiled for use with
all memory models (not just the small memory model
distributed here.)
Registered owners are entitled to utilize TCHK in commercial
applications.
Registered users are registered for all versions of TCHK
numbered 0.xx and 1.xx. Beyond that I make no guarrantees.
When I release 1.00 I will decide how I will handle future
updates. (Check the versions I've released and you'll notice
I pack a lot in. This isn't such a bad deal.)
REGISTERED owners may purchase the source code to TCHK for $35.
Businesses using TCHK, for whatever reason, MUST register.
Page 4
Nonregistered users releasing a program as Public Domain that
uses TCHK is a violation of the law. Use it by yourself, for
yourself, for a personal (not business) reason, and you do not
have to register.
BACKGROUND
I am a student at Rensselaer Polytechnic Institute majoring in
computer science. I also do consulting/programming work as a
sideline (hint hint.) When I purchased Turbo C, I wanted to do
more than bare bones printf(). I was also engaged in designing
some software requiring the use of dates, and some other unusual
functions. Thus, after several months of testing and use, I
developed a rather useful collection of functions. After some
requests from other programmers, I decided to bundle most of them
together and <gasp> document them. This library is a collection of most
of these functions.
FILES
You may not distribute TCHK except in unmodified form, and it
must be distributed with all the following files:
TCHKS.LIB - small memory model library
TCHK.DOC - documentation for TCHK
DEMODATE.C - demo program of date functions
DEMODATE.PRJ - project used to compile DEMODATE.C
DEMODISK.C - demo program of disktype function
DEMODISK.PRJ - project used to compile DEMODISK.C
DEMOMENU.C - demo program of menu functions
DEMOMENU.PRJ - project used to compile DEMOMENU.C
TCHK.TC - Turbo C configuration file
ANSIHK.H - header file for ANSI functions
COLOR.H - color definitions
DATEHK.H - header file for date routines
FILEHK.H - header file for file routines
IBM.H - header file for misc. IBM routines
KEYBOARD.H - header file for keyboard routines
KEYCODE.H - keyboard scan codes
MATHHK.H - header file of math defines
MENUHK.H - header file for menu routines
MULTIHK.H - header file for multi-tasking functions
STRINGHK.H - header file for string routines
TIMEHK.H - header file for time routines
VIDEO.H - header file for video routines
To compile the demo programs, use the configuration file TCHK.TC
and the appropriate project file. Make sure you check the Turbo C
directories before compiling.
Page 5
IN THE BEGINNING...
Except where explicitly stated, all of these functions have been
tested and compiled on my system:
- IBM PC
- 640K memory
- (CGA) Color Graphics Adapter
- DOS 3.2
- IBM Proprinter XL
TCHK was compiled from the interactive environment of Turbo C,
with the following options changed from the default:
Optimize on: SPEED
Memory model: SMALL
For more info, check out the configuration file TCHK.TC.
This library was written in 100% Turbo C, with no use of inline
Assembly, compiled with Turbo C 1.0 and created with PLIB86.
FEATURES
TCHK sports many useful features not found in other shareware
packages. Aside from many input and output routines, TCHK is the
only package I have seen (and I've looked) that supplies date and
time functions. Also unique to TCHK is the Lotus style slash-bar
menu function.
Many of the functions requiring output as a side effect (most
noticeably the keyboard functions) make use of some of the output
routines prototyped in VIDEO.H. If you use almost any of the
keyboard routines, expect both the keyboard and the video
routines to be linked into your program. This is true of some of
the other routines as well (the lotus menus require the menu,
keyboard, video and time routines.) Since the entire .LIB file is
rather small, there is no harm done. Perhaps a future version
will have the routines segmented more (if you really want to
break up the library, you can always purchase the source code...)
CREDIT
The following people deserve credit for their help:
James Arnold helping with optimizing the direct video access
functions.
Darius Thabit for his help with the reboot function.
Page 6
FUNCTIONS
Most of the functions are documented well enough below, although
I feel a few more explanations are necessary:
In the interactive environment you can #define one item in
terms of another, including spaces. If anyone knows how to
do this with the command line version, please let me know.
The variable type byte is just an unsigned char. If you
use the command line version of TC you will have to change
the header files of TCHK.
All functions asking for screen coordinates treat the top
left corner as row zero, column zero (0,0).
Most functions rely on interrupts and low memory addresses
(400:xxxx) to comply with the IBM standard. Certain values
(for instance, the current video page) can be found by an
interrupt or by peeking at the value stored in low memory.
Many of the video functions especially require these values
to be found at the proper places. If your clone is radically
different from the IBM standard some of these functions may
not work properly. I didn't want to have to write a million
small functions that are just background support for the
functions found here (like current page number, etc.) so I
used the #defines found in the headers (see video.h for more
details.)
TCHK has not been tested on a Hercules or MDA video card
since I do not have access to either piece of hardware,
although the methods I used are well documented and should
cause no problems.
All direct screen accesses have built-in snow control. On
CGA monitors, the snow was horrendous without it. Unless I
code these routines in assembler, I won't be able to squeeze
any more optimization out of these routines. I do plan on
converting these functions to assembler, but I just don't
have the time right now.
One type of command you will NOT find in TCHK are windowing
commands. There are plenty of windowing libraries available. You
should not try to make your poor IBM into a Mac, it won't cut it.
Splurge for the Mac, you'll be happier. Yes, I know, the
'windowing' interface is nicer. I use 'windows' too, although
mine are just boxes. I find it more than suitable for my current
needs.
The functions are listed in the same manner as the Turbo C
manual, in alphabetical order.
Page 7
Name ansi_call - create an ANSI escape sequence
Usage char *ansi_call(int subfunction, int parm1,
int parm2, char *ansistring);
Prototype in ansihk.h
Description ansi_call is a general function that will create
an ANSI escape sequence for the given subfunction:
1: gotoxy(parm1,parm2)
2: cursor_right
3: cursor_left
4: cursor_up
5: cursor_down
6: save_cursor_position
7: restore_cursor_position
8: cls()
9: clear_eol()
10: set_foreground(parm1)
11: set_background(parm1)
12: clear_attributes (plain, normal)
13: bold
14: faint
15: italic
16: blink
17: fast_blink
18: inverse
19: invisible
20: set_mode(parm1)
21: reset_mode(parm1)
22: wherexy()
1: moves cursor to (parm1,parm2)
2-5: move cursor 1 space in direction indicated
6-7: save cursor position for future restoring
8: clear screen
9: clear to the end of current line
10-11: set colors for output
12-15,18-19: set attributes for output
16-17: control cursor blink rate
20-21: change mode (not same as DOS, see ansihk.h)
22: outputs the current cursor location
A value must be passed for parm1 and parm2, even
if they are not going to be used.
The escape sequence ansistring can be outputted
with a simple printf().
Remember, ANSI.SYS, FANSI-CONSOLE, or some similar
ANSI control sequence program must be active for
these codes to take effect.
Page 8
Return value returns ansistring.
Note The color codes needed by ANSI functions are NOT
the same as the color codes used by DOS to set
attributes. Use the ANSI color #defines given in
ansihk.h.
Page 9
Name atrim - trims leading and trailing blanks
ltrim - trims leading blanks
rtrim - trims trailing blanks
Usage char *atrim(char *source);
char *ltrim(char *source);
char *rtrim(char *source);
Prototype in stringhk.h
Description these functions remove leading and/or trailing
blanks in a string.
Return value returns a pointer to the storage location
containing the trimmed string, or NULL if space
could not be allocated. The returned string is NOT
the same as the string passed to the function.
This function does NOT write over the string
passed to it.
Example #include <stringhk.h>
#include <stdio.h> /* for the printf */
main()
{
char msg[25], *trimmed
strcpy(msg," Hello everyone ");
trimmed = ltrim(msg);
printf("String [%s]\n",msg);
printf("ltrim [%s]\n",trimmed);
free(trimmed);
trimmed = rtrim(msg);
printf("rtrim [%s]\n",trimmmed);
free(trimmed);
trimmed = atrim(msg);
printf("atrim [%s]\n",trimmmed);
}
Program output String [ Hello everyone ]
ltrim [Hello everyone ]
rtrim [ Hello everyone]
atrim [Hello everyone]
Page 10
Name box - draw a box
Usage int box(int top, int left, int bottom, int right,
byte frame[]);
Prototype in video.h
Description draws a box via INTerrupts.
frame must be have at least 9 elements (byte
frame[9]). The box characters are frame[0] (top
left) to frame[7] (left wall), going clockwise. If
frame[8] != '\0' the box is filled with it.
Return value returns zero upon succesful completion, -1 if
invalid coordinates are given.
See also global variables
horiz_line(), restore_box(), restore_screen(),
save_box(), save_screen(), vert_line()
Example #include <video.h>
main()
{
byte framebox[9];
strcpy(framebox,"abcdefghi");
box(1,4,4,10,framebox);
}
Program output abbbbbc
hiiiiid
hiiiiid
gfffffe
Page 11
Name Cal... - family of Calendar date conversion
functions
Usage char *CaltoGreg(double cal);
char *CaltoGregEuro(double cal);
char *CaltoGregJap(double cal);
double CaltoJul(double cal);
double CaltoJulA(double cal);
double CaltoJulB(double cal);
double CaltoCalCent(double cal);
double CalCenttoCal(double cal);
Prototype in datehk.h
Description CaltoGreg converts Calendar date to
Gregorian (US) date
CaltoGregEuro converts Calendar date to
Gregorian (European) date
CaltoGregJap converts Calendar date to
Gregorian (Japan) date
CaltoJul converts Calendar date to
Julian (Type E) date
CaltoJulA converts Calendar date to
Julian (Type A) date
CaltoJulB converts Calendar date to
Julian (Type B) date
CaltoCalCent converts Calendar date to
Calendar date (w/century)
CalCenttoCal converts Calendar date
(w/century) to Calendar date
Return value CaltoGreg... return the appropriate Gregorian date
CaltoJul... return the appropriate Julian date
CaltoCalCent returns a Calendar date (w/century)
CalCentotCal returns a Calendar date
See also Appendix A
fulltoddate(), Greg...(), Jul...(), shorttoddate()
Example see demodate.c
Page 12
Name clear - clears a portion of the screen
Usage void clear(int top, int left, int bottom, int
right);
Prototype in video.h
Description clears a box of the screen with INT 0x10, Service
6.
Return value nothing.
See also cls()
Example #include <video.h>
main()
{
clear(0,0,3,79); /* clear top 4 lines of
screen */
}
Page 13
Name clear_typeahead - clear typeahead buffer
Usage int clear_typeahead(void);
Prototype in keyboard.h
Description clears the typeahead buffer and returns the number
of keystrokes cleared
Return value number of keystrokes emptied from the typeahead
buffer
Example #include <keyboard.h>
#include <stdio.h>
main()
{
printf("# keystrokes emptied = %d",
clear_typeahead());
}
Page 14
Name cls - clear screen
Usage void cls(void);
Prototype in video.h
Description clears screen by INT 0x10, Service 6 (scroll
window up) and resets cursor to (0,0).
Return value nothing.
See also clear()
Example #include <video.h>
main()
{
cls()
}
Page 15
Name cursor_blink - set speed of cursor blink
Usage void cursor_blink(boolean fast);
Prototype in video.h
Description this function will make the cursor blink fast if
fast is TRUE, or slow if fast is FALSE.
Return value nothing.
See also cursor_flip(), cursor_off(), cursor_on(),
read_cursor(), set_cursor()
Example
Program output
Page 16
Name cursor_flip - toggle the cursor type
Usage void cursor_flip(unsigned int curs1, unsigned int
curs2);
Prototype in video.h
Description toggles the cursor scan lines to whichever set the
cursor is not currently set for.
Return value nothing.
See also cursor_blink(), cursor_off(), cursor_on(),
read_cursor(), set_cursor()
Example #include <video.h>
main()
{
cursor_flip(CURSOR_UNDERBAR,CURSOR_HALFBLOCK);
}
Page 17
Name cursor_off - turn the cursor off
Usage void cursor_off(void);
Prototype in video.h
Description makes the cursor invisible.
Return value nothing.
See also cursor_blink(), cursor_flip(), cursor_on(),
read_cursor(), set_cursor()
Example #include <video.h>
main()
{
cursor_off();
}
Page 18
Name cursor_on - turn the cursor on
Usage void cursor_on(void);
Prototype in video.h
Description makes the cursor visible. Sets the scan lines to
the default according to the hardware detected.
Return value nothing.
See also cursor_blink(), cursor_flip(), cursor_off(),
read_cursor(), set_cursor()
Example #include <video.h>
main()
{
cursor_on();
}
Page 19
Name dayofweek - find the day of the week
Usage int dayofweek(double jul);
Prototype in datehk.h
Description finds the day of the week for a given Julian
(Type E) date
Return value returns 0-6 (Sun...Sat)
See also Appendix A
datehk.h
Example see demodate.c
Page 20
Name dayofyear - calculate the day of the year
Usage int dayofyear(struct ddate *d);
Prototype in datehk.h
Description dayofyear calculate the day of the year given a
date. The day of the year will range from 1
(January 1) to 365 (Dec 31, no leap year) or 366
(Dec 31, leap year.)
dayofyear does no error checking on passed
parameters.
Return value returns a number from 1 to 365 (no leap year) or
366 (leap year.)
See also daysleft(), diffddate()
Example #include <datehk.h>
main()
{
struct ddate today;
/* set today to Feb 3, 1987 */
printf("%d/%d = day %d\n", today.dmon,
today.dday, dayofyear(&today));
}
Program output 2/3 = day 34
Page 21
Name daysleft - calculate the days left in the year
Usage int daysleft(struct ddate *d);
Prototype in datehk.h
Description daysleft calculates how many more days are left in
the year. The days left will range from 0 (Dec 31)
to 364 (Jan 1, no leap year) or 365 (Jan 1, leap
year.)
daysleft does no error checking on passed
parameters.
Return value returns a number from 0 to 364 (no leap year) or
365 (leap year.)
See also dayofyear(), diffddate()
Example #include <datehk.h>
main()
{
struct ddate today;
/* set today to Nov 3, 1987 */
printf("%d/%d = %d days left\n", today.dmon,
today.dday, daysleft(&today));
}
Program output 11/3 = 58 days left
Page 22
Name ddatetolong - convert a date to long string
Usage char *ddatetolong(struct ddate *source);
Prototype in datehk.h
Description ddatetolong converts a date from the structure
format ddate to a string in the form
Month dd, Year where
Month = the name of the month ("November")
dd = the day (5, 12, etc.)
Year = the year + 1900
Return value returns a pointer to the storage location
containing the date in string format, or NULL if
space could not be allocated.
See also ddatetoshort(), ddatetostr(), monthexpand(),
strtoddate()
Example #include <datehk.h>
main()
{
struct ddate today;
char *strtoday;
/* assign some value to today */
strtoday = ddatetolong(&today);
printf("today is %d-%d-%d\n", today.dmon,
today.dday, today.dyear);
printf("or %s\n", (strtoday==NULL) ?
"no memory" : strtoday);
}
Page 23
Name ddatetoshort - convert a date to short string
Usage char *ddatetoshort(struct ddate *source);
Prototype in datehk.h
Description ddatetoshort converts a date from the structure
format ddate to a string in the form
Mon dd, Year where
Mon = the abbreviation of the month ("Nov")
dd = the day (5, 12, etc.)
Year = the year + 1900
Return value returns a pointer to the storage location
containing the date in string format, or NULL if
space could not be allocated.
See also ddatetolong(), ddatetostr(), monthexpand(),
strtoddate()
Example #include <datehk.h>
main()
{
struct ddate today;
char *strtoday;
/* assign some value to today */
strtoday = ddatetoshort(&today);
printf("today is %d-%d-%d\n", today.dmon,
today.dday, today.dyear);
printf("or %s\n", (strtoday==NULL) ?
"no memory" : strtoday);
}
Page 24
Name ddatetostr - convert a date to abbrev. string
Usage char *ddatetostr(struct ddate *source);
Prototype in datehk.h
Description ddatetostr converts a date from the structure
format ddate to a string in the form mm-dd-y..y
where the month and day are always 2 digits long
(a 0 is prefix to single digit months and days)
and year is not altered.
Return value returns a pointer to the storage location
containing the date in string format, or NULL if
space could not be allocated.
See also ddatetolong(), ddatetoshort(), monthexpand(),
strtoddate()
Example #include <datehk.h>
main()
{
struct ddate today;
char *strtoday;
/* assign some value to today */
strtoday = ddatetostr(&today);
printf("today is %d-%d-%d\n", today.dmon,
today.dday, today.dyear);
printf("or %s\n", (strtoday==NULL) ?
"no memory" : strtoday);
}
Page 25
Name delay - wait for a time delay
Usage void delay(int wait);
Prototype in timehk.h
Description delay is an empty loop based on the clock that
waits for wait/10 seconds.
wait can be any positive int value (the maximium
wait 32767 is a little less than an hour.) If wait
is negative, erratic behavior may result (it won't
work.)
Return value nothing.
Example #include <timehk.h>
main()
{
delay(5); /* wait for 1/2 second */
delay(600); /* wait for one minute */
Page 26
Name DESQfreeCPU - give up CPU time
Usage void DESQfreeCPU(void);
Prototype in multihk.h
Description this function will free the remaining CPU cycles
under DESQview, Topview and Taskview. I have
tested this function only under DESQview, where I
believe it frees the reamining ticks in the
program's turn. If the foreground/background ticks
are set at 6/4, and the program is in the
foreground, it checks something, and if the
program will just sit idle and chew up CPU time,
calling this function frees whatever remain of its
6 ticks.
Return value nothing.
See also DESQversion()
Page 27
Name DESQversion - DESQview/Topview/Taskview version
Usage int DESQversion(void);
Prototype in multihk.h
Description determines if DESQview/Topview/Taskview is running
and gets the version number
Return value returns zero if DESQview, Topview or Taskview is
not running, otherwise returns the version number.
Note I have only been able to test this under DESQview.
Running under DOS, this function returns zero.
While running under DESQview, DESQversion returns
0xA01, regardless of which version I tried it
under (2.0 or 2.01.) If anyone can offer some
information, I'd appreciate it. For now, assume a
return value of zero means DESQview/Topview/Task-
view is not active, a nonzero return means one of
them is active.
See also DESQfreeCPU()
Example #include <multihk.h>
main()
{
printf("DESQview/Topview/Taskview is ");
if (! isDESQversion())
printf("not ");
printf("running\n");
}
Page 28
Name diffddate - calculate the difference in 2 dates
Usage long int diffddate(struct ddate *start,
struct ddate *fini);
Prototype in datehk.h
Description diffdate calculates the difference in days between
start and fini (fini - start).
diffdate does not perform any error checking on
the passed parameters.
Return value returns the number of days from start to fini.
See also dayofyear(), daysleft(), diffddate()
Example #include <datehk.h>
main()
{
struct ddate begin, end;
long int days;
/* set begin to Jan 1, 1981 */
/* set end to Feb 5, 1982 */
days = diffdate(&begin,&end);
printf("Feb 5, 1982 - Jan 1, 1981 =
%ld\n",days);
}
Program output Feb 5, 1982 - Jan 1, 1981 = 400
Page 29
Name disktype - disk drive type
Usage byte disktype(byte drive);
Prototype in ibm.h
Description disktype will determine the type of disk drive
being tested. drive specifies the drive to check.
Set drive to zero to specify the default drive,
one is A:, two is B:, etc.
Return value returns the drive id byte. See ibm.h for more
details.
Example see testdisk.c
Page 30
Name DoubleDOSfreeCPU - give up CPU time under
Double DOS
Usage void DoubleDOSfreeCPU(byte slices);
Prototype in multihk.h
Description this function frees up CPU time from the current
program. The amount of time freed up is found by
slices * 55ms.
Return value nothing.
See also DoubleDOSTaskSwitch(), isDoubleDOS()
Example #include <multihk.h>
main()
{
DoubleDOSfreeCPU(1000); /* frees 55 secs */
}
Page 31
Name DoubleDOSTaskSwitch - set Double DOS task
switching on/off
Usage void DoubleDOSTaskSwitch(boolean on);
Prototype in multihk.h
Description sets Double DOS task switching on or off.
Return value nothing.
See also DoubleDOSfreeCPU(), isDoubleDOS()
Example #include <multihk.h>
#define ENABLE TRUE
main()
{
DoubleDOSTaskSwitch(ENABLE);
}
Page 32
Name EMMversion - version of Expanded Memory Manager
Usage boolean EMMversion(byte *version);
Prototype in ibm.h
Description finds the version of
Return value returns TRUE if successful (and *version is the
version id,) FALSE if an error occurred (and
*version is the error code.)
Note this function is available under EMM 3.2 specs.
See also ibm.h
isEMSavail()
Example #include <ibm.h>
main()
{
byte *ver;
if (isEMSavail())
if (EMMversion(ver)) /* success */
printf("EMM version id %X\n",*ver);
else /* error */
printf("EMM error code %X\n",*ver);
}
Page 33
Name Extendedtotal - total Extended memory installed
Usage int Extendedtotal(void);
Prototype in ibm.h
Description detects the total amount of Extended memory
installed.
Return value returns the total Extended memory installed, in
Kbytes.
Note you should check for the presence of Extended
memory with isExtended() before using this
function. Calling Extendedtotal() when no Extended
memory is present can lead to unpredictable
results.
See also isEMSavail(), isExtended()
Example #include <ibm.h>
main()
{
printf("Total Extended Memory is %dK\n",
Extendedtotal());
}
Page 34
Name fulltoddate - convert a full date to struct
shorttoddate - convert a short date to struct
Usage struct ddate *fulltoddate(char *source);
struct ddate *shorttoddate(char *source);
Prototype in datehk.h
Description fulltoddate converts a date from a full date
format to the structure ddate format
shorttoddate converts a date from a short date
format to the structure ddate format
Return value returns a pointer to the storage location
containing the date structure, or NULL if space
could not be allocated.
See also see Appendix A
Cal...(), Greg...(), Jul...()
Example see demodate.c
Page 35
Name getc_match - get specific input, case
independent
getk_match - get specific input, case dependent
Usage char getc_match(boolean output, char *match);
char getk_match(boolean output, char *match);
Prototype in keyboard.h
Description these functions accept character input (via
getk()) until one of the characters in the string
match in entered. getk_match waits for an
identical match ('a' != 'A') and getc_match waits
for a similar match ('a' == 'A'). Extended keys
never match (F10 will never be a match.) If output
= TRUE, the character is echoed to the screen via
putk().
Return value returns the key pressed.
See also getk(), getlogical(), getyn()
Example #include <keyboard.h>
main()
{
printf("Enter your choice (Q, X, F, D): ");
getc_match(1,"QXFD");
printf("Enter your sub-choice (abcdHJ): ");
getk_match(1,"abcdHJ");
}
Program output Enter your choice (Q, X, F, D): f
Enter your subchoice (abcdHJ): H
Page 36
Name getddate - inputs a date from the keyboard
Usage char *getddate(void);
Prototype in keyboard.h
Description getddate inputs a date from the keyboard in the
form xx-xx-xx. Only digits, space and backspace
are valid input. Input is terminated when the
ENTER key is pressed. Input is echoed to the
screen via putk().
Return value if a valid date is entered, getddate returns a
string in the form xx-xx-xx, otherwise NULL is
returned.
Example #include <keyboard.h>
#include <stdio.h>
main()
{
char *c;
printf("What is today's date: ");
c = getddate();
printf("Today is %s\n",c);
}
Program output What is today's date: 11-10-87
Today is 11-10-87
Page 37
Name getdouble - inputs a double from the keyboard
Usage char *getdouble(void);
Prototype in keyboard.h
Description getdouble inputs a double from the keyboard. Only
digits, decimal point, leading sign and backspace
are valid input. Input is terminated when the
ENTER key is pressed. Input is echoed to the
screen via putk().
The maximum length of input is 25.
Return value returns a string of the format [sn] [ddd] [.]
[ddd] where
[sn] = optional sign (+ or -)
[ddd] = optional digits
[.] = optional decimal point
See also getint(), getreal()
Example #include <keyboard.h>
#include <stdio.h>
main()
{
char *c;
printf("Give me a double: ");
c = getdouble();
printf("Your input is %s\n",c);
}
Program output Give me a double: -1289.12003
Your input is -1289.12003
Page 38
Name getfname - get a filename from the keyboard
Usage int getfname(byte row, byte col, char *returnstr,
char *pattern, int argn, int argk[]);
Prototype in video.h
Description getfname calls getget() asking for input of a
length 12 string, at the coordinates (col,row),
including pattern formatting and optional input
exit keys listed in argk. If memory was allocated
for returnstr, the string pointed to by returnstr
is checked to see if it is a valid DOS filename. A
valid filename must be of the form
[filename] [.] [ext] and does not contain
any of the following:
[ ] ; , . / ? * : " + = - < > \ |
If memory could not be allocated for the string,
returnstr will be set to NULL.
For more info on pattern and argk requirements,
check the stats for getget().
Return value if memory could not be allocated for returnstr or
the string pointed to by returnstr is not a valid
filename, -1 is returned, otherwise the key used
to exit the input is returned.
See also getget()
Example #include <filehk.h>
#include <keycode.h>
main()
{
char *fname;
int keys[2]={ESC,F10}; /* ESC & F10 exit
input */
gotoxy(0,0);
printf("Enter file: ");
if (getfname(0,13,fname,"!",2,keys) == -1)
printf(" BAD FILENAME");
else
printf(" valid filename");
}
Program output
Page 39
Name getget - get a string from the keyboard
w/editing
Usage int getget(byte row, byte col, char *returnstr,
int size, char *pattern, int argn,
int argk[]);
Prototype in keyboard.h
Description getget inputs a string at coordinates (col,row),
of maximum length size, formatted according to
pattern. Input ends when ENTER or one of the scan
codes specified in argk[] in inputted. There are
argn number of elements in argk[]. The string is
returned in returnstr and the function returns the
scan code of the exiting key.
Full feature editing of the string includes:
ENTER Ends input, exits function
BACKSPACE normal backspace
LEFT ARROW move cursor back 1 character
INSERT toggle inset/overwrite mode
DELETE delete character under cursor
RIGHT ARROW move cursor forward 1
character
HOME move cursor to beginning for
string
END move cursor to end of string
CTRL-Y delete entire string
ALT-Y delete string from cursor to
end
See getstr() for pattern arguments.
Return value returns the scan code of the key causing the exit
See also getstr()
Page 40
Name getint - inputs an integer from the keyboard
Usage char *getint(void);
Prototype in keyboard.h
Description getint inputs an integer from the keyboard. Only
digits, leading sign and backspace are valid
input. Input is terminated when the ENTER key is
pressed. Input is echoed to the screen via putk().
the maximum length of input is 25.
Return value returns a string of the format [sn] [ddd] where
[sn] = optional sign (+ or -)
[ddd] = optional digits
See also getdouble(), getreal()
Example #include <keyboard.h>
#include <stdio.h>
main()
{
char *c;
printf("Give me an integer: ");
c = getint();
printf("Your input is %s\n",c);
}
Program output Give me an integer: -1289
Your input is -1289
Page 41
Name getk - get a key
Usage byte getk(boolean wait);
Prototype in keyboard.h
Description getk returns the scan code of the key pressed. If
no key was pressed (WAIT = FALSE) 0 is returned.
This function is similar to getchar() except input
is not echoed to the screen and getk will detect
any key press (any standard keypress. It cannot
distinguish between the grey '+' key and the white
'+'. This function is interrupt driven. It will
detect ALT combinations, Del, PgUp, function keys,
etc., any keyboard INTerrupt accepted keys.
Return value returns the scancode for the key pressed, from 1
to 255. If WAIT = FALSE, and no key is pressed,
zero is returned. Check the global variables
key_status and key_extended to determine the shift
key status and if the key is an extended one.
See also keycode.h
getc_match(), getk_match(), getlogical(), getyn(),
inkey()
Example #include <keyboard.h>
#include <stdio.h>
main()
{
extern boolean key_extended;
byte c;
c = getk(WAIT);
printf("Key code # in keycode.h: %d\n",
key_extended ? c+256 : c);
}
Page 42
Name getlogical - get Yes/No
Usage char getlogical(int output);
Prototype in keyboard.h
Description getlogical waits for a True/False key (TtFfYyNn)
to be pressed and then displays a message via
putstr() according to output:
output Message displayed
------ -----------------
0 no message
1 T or F or Y or N
2 True or False or Yes or No
getlogical is case independent.
Return value returns 'Y' or 'N'
See also getc_match(), getk(), getk_match(), getyn(),
inkey()
Example #include <keyboard.h>
main()
{
printf("This is good? ");
getlogical(2);
}
Page 43
Name getreal - inputs a real from the keyboard
Usage char *getreal(int size, int decimal);
Prototype in keyboard.h
Description getreal inputs a real (double) from the keyboard.
Only digits, decimal place, leading sign and
backspace are valid input. Input is terminated
when the ENTER key is pressed. Input is echoed to
the screen via putk().
the maximum length of input is size and the
maximum number of decimal places is decimal. When
calculating size, you must leave enough room for
decimal, plus the number of places of the leading
integer, one for the decimal point and one for the
leading sign.
Return value returns a string of the format [sn] [ddd] [.]
[ddd] where
[sn] = optional sign (+ or -)
[ddd] = optional digits
[.] = optional decimal point
See also getdouble(), getint()
Example #include <keyboard.h>
#include <stdio.h>
main()
{
char *c;
printf("Give me a real: ");
c = getreal(8,2);
printf("Your input is %s\n",c);
}
Program output Give me a real: -1012.30
Your input is -1012.30
Page 44
Name getstr - input a string from the keyboard
Usage char *getstr(int size, char *pattern);
Prototype in keyboard.h
Description getstr inputs a string from the keyboard, of
maximum length size, given a format pattern where
pattern format
------- ------
Types a Alphabetic
A Alphabetic and
capitalized
n Alphanumeric
N Alphanumeric and
capitalized
X Ascii (default)
9 Numeric
# Numeric and punctuation
Modifiers ! convert to upper case
. punctuation
( left justify
) right justify
^ center justify
The only other valid keys are backspace and ENTER.
Input is echoed to the screen via putk().
Return value returns a pointer to the storage location
containing the formatted string, or NULL if space
could not be allocated.
See also getget()
Example #include <keyboard.h>
#include <stdio.h>
main()
{
char *f, *l, *s, *c;
printf("First name: ");
f = getget(10,"A");
printf("Last name: ");
l = getget(20,"a");
printf("SS#: ");
s = getget(8,"9");
printf("Comments: ");
c = getget(60,"");
}
Page 45
Program output First name: HOWARD
Last name: kapustein
SS#: 123456789
Comments: The empty quotes defaults to X.
Page 46
Name getyn - get Yes/No
Usage char getyn(int output);
Prototype in keyboard.h
Description getyn waits for a Y or N to be pressed and then
displays a message via putstr() according to
output:
output Message displayed
------ -----------------
0 no message
1 Y or N
2 Yes or No
getyn is case independent.
Return value returns 'Y' or 'N'
See also getc_match(), getk(), getk_match(), getlogical(),
inkey()
Example #include <keyboard.h>
main()
{
printf("Is this OK? ");
getyn(2);
}
Page 47
Name gotoxy - move cursor to coordinates (x,y)
Usage void gotoxy(int x, int y);
Prototype in video.h
Description gotoxy puts cursor at coordinates (x,y) via INT
0x10, Service 2.
Return value nothing.
See also read_cursor(), wherex(), wherey()
Example #include <video.h>
main()
{
gotoxy(4,10); /* put cursor at row 4,
column 10 */
}
Page 48
Name Greg... - family of Gregorian date conversion
functions
Usage double GregtoCal(char *greg);
double GregtoCalCent(char *greg);
double GregEurotoCal(char *greg);
double GregEurotoCalCent(char *greg);
double GregJaptoCal(char *greg);
double GregJaptoCalCent(char *greg);
Prototype in datehk.h
Description GregtoCal converts Gregorian (US) dates
to Calendar dates
GregtoCalCent converts Gregorian (US) dates
to Calendar dates (w/century)
GregEurotoCal converts Gregorian (European)
dates to Calendar dates
GregEurotoCalCent converts Gregorian (European)
dates to Calendar dates
(w/century)
GregJaptoCal converts Gregorian (Japan)
dates to Calendar dates
GregJaptoCalCent converts Gregorian (Japan)
dates to Calendar dates
(w/century)
Return value GregtoCal, GregEurotoCal, GregJaptoCal return a
Calendar date
GregtoCalCent, GregEurotoCalCent, GregJaptoCalCent
return a Calendar date (w/century)
See also Appendix A
Cal...(), fulltoddate(), Jul...(), shorttoddate()
Example see demodate.c
Page 49
Name horiz_line - draw a horizontal line
Usage void horiz_line(byte c, unsigned int len, byte
row,
byte col);
Prototype in video.h
Description draws a horizontal line of characters c of length
len beginning at (col,row) via INTerrupts.
horiz_line does no error checking on the passed
parameters.
Return value nothing.
See also box(), restore_box(), restore_screen(),
save_box(), save_screen(), vert_line()
Example #include <video.h>
main()
{
horiz_line('*',7,4,4); /* draw 7 *'s at
(4,4) */
}
Page 50
Name inkey - get a key
Usage int inkey(boolean wait);
Prototype in keyboard.h
Description inkey returns the scan code of the key pressed. If
no key was pressed (WAIT = FALSE) 0 is returned.
This function is similar to getchar() except input
is not echoed to the screen and getk will detect
any key press (any standard keypress. It cannot
distinguish between the grey '+' key and the white
'+'. This function is interrupt driven. It will
detect ALT combinations, Del, PgUp, function keys,
etc., any keyboard INTerrupt accepted keys.
Return value returns the scancode for the key pressed, from 1
to 511. If WAIT = FALSE, and no key is pressed,
zero is returned.
See also keycode.h
getc_match(), getk(), getk_match(), getlogical(),
getyn()
Example #include <keyboard.h>
#include <stdio.h>
main()
{
int c;
c = inkey(WAIT);
printf("Key code # in keycode.h: %d\n", c);
}
Page 51
Name intlen - calculate length of integer in a string
Usage int intlen(char *number);
Prototype in stringhk.h
Description intlen calculates the length of an integer in the
string number. The integer is terminated by a
non-digit (any character other than 0-9.) This
function is used internally by strcomma.
Return value the length of the integer pointed to by number.
Example #include <stringhk.h>
#include <stdio.h> /* for the printf */
#include <alloc.h> /* for the calloc */
main()
{
char *sint[15];
int len;
strcpy(sint,"1839.44");
printf("String: %s Length of integer:
%d\n", sint, intlen(sint));
strcpy(sint,"19,848");
printf("String: %s Length of integer:
%d\n", sint, intlen(sint));
strcpy(sint,"44x993");
printf("String: %s Length of integer:
%d\n", sint, intlen(sint));
}
Program output String: 1839.44 Length of integer: 4
String: 19,848 Length of integer: 2
String: 44x993 Length of integer: 2
Page 52
Name isBREAKon - check Ctrl-BREAK flag
Usage boolean isBREAKon(void);
Prototype in ibm.h
Description checks the state of the Ctrl-BREAK flag. The BREAK
status flag can be set from DOS by BREAK ON or
BREAK OFF.
Return value returns TRUE if the break flag is on, FALSE if the
flag is off.
See also isVERIFYon(), setBREAK(), setVERIFY()
Example #include <ibm.h>
main()
{
printf("BREAK flag is ");
if (! isBREAKon())
printf("not ");
printf("on\n");
}
Page 53
Name isCGA - is Color Graphics adapter installed
isEGA - is Enhanced Graphics adapter installed
isHerc - is Hercules Graphics adapter installed
isMDA - is Monochrome adapter installed
ismono - is monochrome display
iscolor - is color display
Usage boolean isMDA(void);
boolean isCGA(void);
boolean isEGA(void);
boolean isHerc(void);
boolean ismono(void);
boolean iscolor(void);
Prototype in video.h
Description is...() check if a video adapter is present.
ismono() checks if the display is mono.
iscolor() checks if the display is color.
The ismono() and iscolor() are combinations. Use
them if you wish to check what attributes to use
(underline or red?) and use the adapter functions
(isEGA, etc.) for adapter specific tests.
Return value these functions return TRUE if the video adapter
or type, as the case may be, is present. Otherwise
they return FALSE.
See also video.h
Example #include <video.h>
main()
{
if (ismono()) /* monochrome */
if (isHerc())
printf("Hercules");
else
printf("MDA");
else /* color */
if (isEGA())
printf("EGA");
else
printf("CGA");
}
Page 54
Name isDoubleDOS - is Double DOS active
Usage boolean isDoubleDOS(void);
Prototype in multihk.h
Description checks if Double DOS is active.
Return value returns TRUE if Double DOS is active, FALSE if
Double DOS is not active.
See also DoubleDOSfreeCPU(), DoubleDOSTaskSwitch()
Example #include <multihk.h>
main()
{
printf("Double DOS is ");
if (! isDoubleDOS())
printf("not ");
printf("active\n");
}
Page 55
Name isEMSavail - is EMS available
Usage boolean isEMSavail(void);
Prototype in ibm.h
Description checks if an EMS device is installed.
Return value returns TRUE if EMS is present, otherwise FALSE.
See also ibm.h
EMMversion(), isExtended(), Extendedtotal()
Example #include <ibm.h>
main()
{
printf("EMS is ");
if (! isEMSavail())
printf("not ");
printf("available\n");
}
Page 56
Name isExtended - is Extended memory installed
Usage boolean isExtended(void);
Prototype in ibm.h
Description checks if Extended memory is installed.
Return value returns TRUE if Extended memory is installed,
FALSE otherwise.
See also isEMSavail(), Extendedtotal()
Example #include <ibm.h>
main()
{
printf("Extended memory is ");
if (! isExtended())
printf("not ");
printf("installed\n");
}
Page 57
Name isleapyear - is a year a leap year
Usage boolean isleapyear(int checkyear);
Prototype in datehk.h
Description checks if checkyear is a leap year (29 days in
February.)
Return value returns TRUE if checkyear is a leap year, FALSE
otherwise.
See also valid_date()
Example #include <datehk.h>
main()
{
int year;
/* assign some value to year */
printf("year %d is ",year);
if (! isleapyear(year))
printf("not ");
printf("a leap year\n");
}
Page 58
Name isNetwork - is a network installed
Usage boolean isNetwork(void);
Prototype in ibm.h
Description checks if a network is installed.
Return value returns TRUE if a network is installed, FALSE
otherwise.
Note this function requires DOS 3.1+
Example #include <ibm.h>
main()
{
printf("A network is ");
if (! isNetwork())
printf("not ");
printf("installed\n");
}
Page 59
Name isVERIFYon - check VERIFY flag
Usage boolean isVERIFYon(void);
Prototype in ibm.h
Description checks the state of the verify flag. The VERIFY
status flag can be set from DOS by VERIFY ON or
VERIFY OFF.
Return value returns TRUE if the verify flag is on, FALSE if
the flag is off.
See also isBREAKon(), setBREAK(), setVERIFY()
Example #include <ibm.h>
main()
{
printf("VERIFY flag is ");
if (! isVERIFYon())
printf("not ");
printf("on\n");
}
Page 60
Name Jul... - family of Julian date conversion
functions
Usage double JultoCal(double jul);
double JultoCalCent(double jul);
char *JultoGreg(double jul);
char *JultoGregEuro(double jul);
char *JultoGregJap(double jul);
struct ddate *Jultoddate(double jul);
double JulAtoCal(double jul);
double JulAtoCalCent(double jul);
char *JulAtoGreg(double jul);
char *JulAtoGregEuro(double jul);
char *JulAtoGregJap(double jul);
struct ddate *JulAtoddate(double jul);
double JulBtoCal(double jul);
double JulBtoCalCent(double jul);
char *JulBtoGreg(double jul);
char *JulBtoGregEuro(double jul);
char *JulBtoGregJap(double jul);
struct ddate *JulBtoddate(double jul);
Prototype in datehk.h
Description Jul.toCal converts a Julian date to
Calendar date
Jul.toCalCent converts a Julian date to
Calendar date (w/century)
Jul.toGreg... converts a Julian date to the
appropraite Gregorian date
Jul.toddate converts a Julian date to
struct ddate
Return value Jul.toCal return a Calendar date
Jul.toCalCent return a Calendar date (w/century)
Jul.toGreg.. return the appropriate Gregorian date
Jul.toddate return a struct ddate
See also Appendix A
Cal...(), fulltoddate(), Greg...(), shorttoddate()
Example see demodate.c
Page 61
Name leftstr - return the left portion of string
midstr - return a piece of a string
rightstr - return the right portion of a string
Usage char *leftstr(char *source, int len);
char *midstr(char *source, int begin, int len);
char *rightstr(char *source, int len);
Prototype in stringhk.h
Description these functions perform just like their BASIC
counterparts LEFT$(), RIGHT$() and MID$().
leftstr returns the left part of a string.
midstr returns the middle part of a string.
rightstr returns the right part of a string.
Return value leftstr returns the leftmost len characters of
source. If the length of source is less than len,
the entire string is returned.
midstr returns the substring of source, using
begin as the offset from the beginning to start
the substring, for len characters.
rightstr returns the rightmost len characters of
source. If the length of source is less than len,
the entire string is returned.
All these functions return a pointer to the
storage location containing the new string, or
NULL if space could not be allocated.
Example #include <stringhk.h>
#include <stdio.h> /* for the printf */
main()
{
char msg[25], *l, *r, *m;
strcpy(msg,"This is another test");
l = leftstr(msg,7);
r = right(msg,7);
m = midstr(msg,5,7);
printf("%s\n",msg);
printf("%s\n",l);
printf("%s\n",r);
printf("%s\n",m);
}
Page 62
Program output This is another test
This an
er test
is anot
Page 63
Name lotus_setup - creates info for menu_lotus()
Usage void lotus_setup(int argc, byte *command[],
char cmdkey[], byte col[], byte
*message[], byte msglen[]);
Prototype in menuhk.h
Description lotus_setup does a lot of the grunt work necessary
to use menu_lotus() properly. Given the command
and message lists this function will create
cmdkey[], col[] and msglen[].
Return value nothing.
See also menu_lotus()
Example see demo.c
Page 64
Name memory_strategy - get/set memory alloc strategy
Usage int memory_strategy(boolean read, int *strategy);
Prototype in ibm.h
Description this function will get or set the memory
allocation strategy. The variable read determines
whether the function will read or write (get or
set) the strategy value stored at *strategy.
Return value returns zero if successful (and *strategy is the
strategy being used) or, if an error occurs, the
error code (in which case the value in *strategy
is meaningless.)
Note this function requires DOS 3.xx.
See also ibm.h
Example #include <ibm.h>
#define GET TRUE /* read */
#define SET FALSE /* write */
main()
{
int memstrat;
if (memory_strategy(GET,&memstrat) !=
MEM_STRAT_BEST)
memory_strategy(SET,MEM_STRAT_BEST);
}
/* Bad, no error checking done. When you document
30 functions, you write the best code, don't you? */
Page 65
Name menu_lotus - Lotus style menu
Usage char menu_lotus(int argc, char cmdkey[], byte
*command[], byte col[], byte *message[],
byte msglen[], byte normal,
byte highlite, byte cmdrow,
boolean clockon, byte
clockrow, byte clockcol, byte
clockcolor);
Prototype in menuhk.h
Description menu_lotus displays a Lotus style 'slash bar' menu
and waits for a menu selection. This function is
modeled after the slash bar menu in Symphony. The
function parameters are:
argc number of menu choices
cmdkey array of the 1st letter of
each command (must be
capitalized)
command menu choices
col columns of 1st letters of menu
commands (for displaying
command line)
message respective messages for menu
commands
msglen lengths of messages
normal color of text
highlite color of highlited option
cmdrow row to display command line on
clockon flag: display a clock?
clockrow row coordinate of clock
clockcol column coordinate of clock
clockcolor color of clock
menu_lotus will display an optional clock (clockon
= TRUE) that is updated every minute. The clock is
displayed as 11:44 PM.
All elements of cmdkey[] MUST be capitalized.
menu_lotus provides limited cursor control, as per
Symphony:
Up Arrow \ move highlite left 1 choice
Left Arrow /
Down Arrow \ move highlite right 1 choice
Right Arrow /
Home highlites first command
End highlites last command
Enter selects highlited menu choice
ESCape selects nothing. Returns ESC
code
Page 66
The cursor keys do not wraparound. Pressing right
arrow at the last menu choice does nothing.
All output is done via putstr().
Return value returns the upper of the 1st letter of the menu
choice selected, or ESC (0x27) if ESC was pressed
See also lotus_setup()
Example see testmenu.c
Page 67
Name monthexpand - convert a month abbrev to its name
Usage char *monthexpand(int month);
Prototype in datehk.h
Description monthexpand returns the name of a month given its
numeric abbreviation.
monthexpand returns an element of a static char
array, so you should not make any changes directly
to the returned value, but rather copy the
returned value to a safe piece of memory.
Return value returns a pointer to the storage location
containing the date structure, or NULL if the
month given is invalid.
See also ddatetolong(), ddatetoshort(), ddatetostr(),
monthexpand(), strtoddate()
Example #include <datehk.h>
main()
{
printf("Month 4 = %s\n",monthexpand(4));
}
Program output Month 4 = April
Page 68
Name putk - put a character w/attribute on the screen
Usage void putk(byte c);
Prototype in video.h
Description putk puts character c on the screen at the cursor
via INTerrupts. The cursor does NOT advance. The
attribute is set with the global variable
char_attribute.
Return value nothing.
See also putsay(), putstr(), set_color()
Example #include <video.h>
main()
{
gotoxy(12,40);
putk('*');
}
Page 69
Name putsay - put a string with attribute on the
screen
Usage void putsay(byte row, byte col, byte *c);
Prototype in video.h
Description putsay puts string c on the screen at location
(col,row) via direct screen writes. It does
retrace checking to prevent snow on CGA systems.
The attribute is set with the global variable
char_attribute.
Return value nothing.
See also putk(), putstr(), set_color()
Example #include <video.h>
main()
{
putstr(12,40,(byte *)"Hello");
}
Page 70
Name putstr - put a string with attribute on the
screen
Usage void putstr(byte *c);
Prototype in video.h
Description putstr puts string c on the screen at the cursor
via INTerrupts. When finished the cursor will be 1
spot after the string. The attribute is set with
the global variable char_attribute.
Return value nothing.
See also putk(), putsay(), set_color()
Example #include <video.h>
main()
{
gotoxy(12,40);
putstr((byte *)"Hello");
}
Page 71
Name read_cursor - reads cursor information
Usage unsigned int read_cursor(byte *row, byte *col);
Prototype in video.h
Description reads the cursor location and scan lines via
INTerrupts.
Return value returns the scan lines of the cursor as a word,
the high order byte the start and low order byte
the end.
See also cursor_blink(), cursor_flip(), cursor_off(),
cursor_on(), set_cursor(), wherex(), wherey()
Example #include <video.h>
main()
{
byte x,y;
unsigned int scan;
scan = read_cursor(&x,&y);
printf("Scan start %d and end %d\n",
scan&0xFF00, scan&0xFF);
}
Program output Scan start 6 and end 7 /* on CGA */
Page 72
Name read_mode - find screen width, mode and page
Usage void read_mode(byte *width, byte *mode, byte
*page);
Prototype in video.h
Description detects the screen width (number of columns,)
video mode and video page via INT 0x10, Service
0x0F.
Return value nothing.
See also video.h
set_mode()
Example #include <video.h>
main()
{
byte width, mode, page;
read_mode(&width, &mode, &page);
printf("# columns: %d Mode: %d Page:
%d\n", width, mode, page);
}
Program output # columns: 80 Mode: 3 Page: 1
Page 73
Name reboot - reboots the machine
Usage void reboot(boolean warmboot);
Prototype in ibm.h
Description calling this function will reboot your machine via
the ROM reboot code located at F000:000. You can
specify a warm or cold boot (like hitting
CTRL-ALT-DEL or turning the power on.)
Return value nothing.
Example #include <ibm.h>
main()
{
boolean bootstyle;
/* set bootstyle */
reboot(bootstyle);
}
Page 74
Name restore_box - restore a part of the screen
Usage void restore_box(byte top, byte left, byte bottom,
byte right, byte *buffer);
Prototype in video.h
Description restore_box restores part of the current screen
(characters and attributes,) from a block of
memory to the display memory, over the area
delineated by the box coordinates.
restore_box will write buffer's contents to the
display memory over the location given by the box
coordinates. With this function it is possible to
restore a screen segment multiple times to
different areas of the screen, allowing quick
display of multiple images.
Return value nothing.
See also restore_screen(), save_box(), save_screen(),
scrbuff()
Example #include <video.h>
main()
{
byte buffer[0x2000];
save_box(0,0,25,39,buffer);
/* save left half of the screen */
restore_box(0,40,25,79,buffer);
/* restore it on the right half of screen */
}
Page 75
Name restore_screen - restore screen
Usage void restore_screen(byte *buffer);
Prototype in video.h
Description restore_screen restores the current screen
(characters and attributes) from a block of
memory.
restore_screen will copy 4K from the memory
location pointed to by buffer to the display
memory.
Return value nothing.
See also restore_box(), save_box(), save_screen(),
scrbuff()
Example #include <video.h>
main()
{
byte buffer[0x4000];
save_screen(buffer);
/* display some stuff */
restore_screen(buffer);
}
Page 76
Name ROM_date - gets the ROM id date
Usage byte ROM_date(void);
Prototype in ibm.h
Description finds the ROM id date at F000:FFF5
Return value returns a pointer to the storage location
containing the string, or NULL if space could not
be allocated.
See also ROM_id()
Example #include <ibm.h>
#include <stdio.h>
main()
{
printf("ROM BIOS date = %s",ROM_date());
}
Program output ROM BIOS date = 06/10/85
Page 77
Name ROM_id - gets the ROM id byte
Usage byte ROM_id(void);
Prototype in ibm.h
Description finds the ROM id byte at F000:FFFE
Return value returns the ROM id byte
Note on Compaq machines the ROM id byte is found at a
memory location close to, but not at, F000:FFFE.
Not having access to a Compaq, I did not include a
check for this. Maybe a future version...
See also ROM_date()
Example #include <ibm.h>
#include <stdio.h>
main()
{
printf("ROM id byte = %X",ROM_id());
}
Program output ROM id byte = FF
Page 78
Name save_box - save a part of the screen
Usage void save_box(byte top, byte left, byte bottom,
byte right, byte *buffer);
Prototype in video.h
Description save_box saves part of the current screen
(characters and attributes,) delineated by the box
coordinates, to a block of memory.
buffer MUST be at least big enough to store the
box. save_box will write over memory beginning
with the memory location pointed to by buffer.
Return value nothing.
See also restore_box(), restore_screen(), save_screen(),
scrbuff()
Example #include <video.h>
main()
{
byte buffer[0x2000];
save_box(0,0,25,39,buffer); /* save left
half */
} /* of screen
*/
Page 79
Name save_screen - save screen
Usage void save_screen(byte *buffer);
Prototype in video.h
Description save_screen saves the current screen (characters
and attributes) to a block of memory.
buffer MUST be at least 4K big. save_screen will
write over 4K beginning with the memory location
pointed to by buffer.
Return value nothing.
See also restore_box(), restore_screen(), save_box(),
scrbuff()
Example #include <video.h>
main()
{
byte buffer[0x4000];
save_screen(buffer);
}
Page 80
Name scrbuff - calculate size of screen buffer
Usage #define scrbuff(t,l,b,r)
Prototype in video.h
Description this is really just a define to calculate the size
of a buffer need by the save_screen() and
save_box() functions.
Return value returns the number of bytes needed to store a
segment of screen from (t,l) to (b,r), with
attributes.
See also video.h
restore_box(), restore_screen(), save_box(),
save_screen()
Example #include <video.h>
main()
{
byte buffer[scrbuff(0,0,25,39)];
save_box(0,0,25,39,buffer);
/* save left half of the screen */
restore_box(0,40,25,79,buffer);
/* restore it on the right half of screen */
}
Page 81
Name scroll_down - scroll window down
Usage void scroll_down(byte top, byte left, byte bottom,
byte right);
Prototype in video.h
Description scroll box delineated by the coordinates down 1
line. A blank line will be inserted at the top,
and the bottom line will be lost.
Return value nothing.
See also scroll_up()
Example #include <video.h>
main()
{
scroll_down(0,0,4,79);
/* scroll bottom 4 lines */
}
Page 82
Name scroll_up - scroll window up
Usage void scroll_up(byte top, byte left, byte bottom,
byte right);
Prototype in video.h
Description scroll box delineated by the coordinates up 1
line. A blank line will be inserted at the bottom,
and the top line will be lost.
Return value nothing.
See also scroll_down()
Example #include <video.h>
main()
{
scroll_up(0,0,4,79); /* scroll top 4 lines */
}
Page 83
Name setBREAK - set Ctrl-BREAK flag
Usage boolean setBREAK(boolean break_status);
Prototype in ibm.h
Description sets the state of the Ctrl-BREAK flag. The BREAK
status flag can be set from DOS by BREAK ON or
BREAK OFF.
Return value returns TRUE if the break flag is on, FALSE if the
flag is off.
Note the return value is based on the CURRENT setting.
If you set the break flag, setBREAK will return
what you set the flag to, not what the flag was
set to before.
See also isBREAKon(), isVERIFYon(), setVERIFY()
Example #include <ibm.h>
main()
{
printf("BREAK flag was ");
if (! setBREAK(TRUE))
printf("not ");
printf("on\n");
}
Page 84
Name set_color - set the default attribute (color)
Usage void set_color(byte colors);
Prototype in video.h
Description set_color just sets the global variable
char_attribute to colors. I got tired of declaring
char_attribute as extern in every function that
output to the screen, so I made this function.
Return value nothing.
See also putk(), putstr()
Example #include <video.h>
#include <color.h>
main()
{
set_color(RED | B_WHITE | BLINK);
/* red blinking text on white background */
gotoxy(12,40);
putstr((byte *)"Hello");
}
Page 85
Name set_cursor - sets cursor scan lines
Usage void set_cursor(byte start, byte end);
Prototype in video.h
Description sets the cursor scan lines via INTerrupts.
Return value nothing.
See also cursor_blink(), cursor_flip(), cursor_off(),
cursor_on(), read_cursor()
Example #include <video.h>
main()
{
set_cursor(0,7);
}
Page 86
Name set_handles - set handle count
Usage int set_handles(int handles);
Prototype in filehk.h
Description sets the handle count via DOS Function 0x67. If
more than 255 handles are specified (the maximum
allowable) set_handle tried to set the handle
count to 255.
Return value returns zero if execution was successful, a
nonzero error code otherwise.
Note This function requires DOS 3.3+.
Example #include <filehk.h>
main()
{
set_handles(127);
}
Page 87
Name setVERIFY - set VERIFY flag
Usage boolean setVERIFY(boolean verify_status);
Prototype in ibm.h
Description sets the state of the verify flag. The VERIFY
status flag can be set from DOS by VERIFY ON or
VERIFY OFF.
Return value returns TRUE if the verify flag is on, FALSE if
the flag is off.
Note the return value is based on the CURRENT setting.
If you set the verify flag, setVERIFY will return
what you set the flag to, not what the flag was
set to before.
See also isBREAKon(), isVERIFYon(), setBREAK()
Example #include <ibm.h>
main()
{
printf("VERIFY flag was ");
if (! setVERIFY(TRUE))
printf("not ");
printf("on\n");
}
Page 88
Name set_mode - set the video mode
Usage void set_mode(byte mode);
Prototype in video.h
Description sets the video mode via INT 0x10, Service 0.
Return value nothing.
See also video.h
read_mode()
Example #include <video.h>
main()
{
set_mode(3); /* text mode */
printf("# columns: %d Mode: %d Page:
%d\n", width, mode, page);
}
Program output # columns: 80 Mode: 3 Page: 1
Page 89
Name strcomma - convert a string to xx,xxx,xxx format
Usage char *strcomma(char *source);
Prototype in stringhk.h
Description strcomma converts a string of numbers into the
comma delimited format (xx,xxx,xxx). The number is
terminated by a non-digit (any character other
than 0-9.) A leading sign will be copied before
converting the number. This function is used
internally by strtodol.
Return value returns a pointer to the storage location
containing the comma formatted string, or NULL if
space could not be allocated. The returned string
is NOT the same as the string passed to the
function. This function does NOT write over the
string passed to it.
Example #include <stringhk.h>
#include <stdio.h> /* for the printf */
main()
{
char sint[15], *comma
strcpy(sint,"12839.44");
comma = strcomma(sint);
printf("%s -> %s\n",sint,comma);
}
Program output 12839.44 -> 12,839.44
Page 90
Name strdel - delete part of a string
Usage char *strdel(char *source, char *old);
Prototype in stringhk.h
Description strdel deletes the first occurence of the string
old from the string source. This function is case
dependent.
Return value returns source
Example #include <stringhk.h>
#include <stdio.h> /* for the printf */
main()
{
char msg[45], fragment[15];
strcpy(msg,"Did you register yet? Did you?");
strpy(fragment,"you");
printf(" [%s]\n",msg);
printf("- [%s]\n",fragment);
printf("= [%s]\n",msg);
}
Program output [Did you register yet? Did you?]
- [you]
= [Did register yet? Did you?]
Page 91
Name strins - insert one string into another
Usage char *strins(char *source, char *new, char *ptr);
Prototype in stringhk.h
Description strins inserts the string new into the string
source at the location ptr in source. Basically,
strins copies source up to, but not including, ptr
into a new location, concatenates the new
(inserted) string, and then concatenates the
remainder of source (the string pointed to by
ptr.)
Return value returns a pointer to the storage location
containing the newly concatenated string, or NULL
if space could not be allocated. The returned
string is NOT the same as the string passed to the
function. This function does NOT write over the
string passed to it.
Example #include <stringhk.h>
#include <stdio.h> /* for the printf */
main()
{
char old[25], *ptr, *new;
strcpy(old,"ABCDEFG");
ptr = old + 3; /* *ptr = 'D' */
new = strins(old,"abc",ptr);
printf("%s -> %s\n",old,new);
}
Program output ABCDEDFG -> ABCabcDEFG
Page 92
Name strrep - replicate a char
Usage char *strrep(char c, int len);
Prototype in stringhk.h
Description strrep copies creates a string len long entirely
of character c.
Return value returns a pointer to the storage location
containing the newly replicated string, or NULL if
space could not be allocated.
Example #include <stringhk.h>
#include <stdio.h> /* for the printf */
main()
{
char *rep;
printf("%s\n",rep = strrep('k',7));
}
Program output kkkkkkk
Page 93
Name strshleft - shift string left
strshright - shift string right
Usage void strshleft(char *source, int count);
void strshright(char *source, int count);
Prototype in stringhk.h
Description these functions shift the characters in the string
source left or right, respectively, count places,
padding with spaces.
Return value returns source.
Example #include <stringhk.h>
#include <stdio.h> /* for the printf */
main()
{
char msg[25];
strcpy(msg,"Buy a Mac II");
printf("%s\n",msg);
printf("%s\n",strshleft(msg,4));
printf("%s\n",strshright(msg,4));
}
Program output Buy a Mac II
a Mac II
Buy a Ma
Page 94
Name strtoddate - convert a date string to a
structure
Usage struct ddate *strtoddate(char *source);
Prototype in datehk.h
Description strtoddate converts a date abbreviation to a
structure of type ddate. The abbreviation can use
dashes or slashes (- or /) to separate the fields
of the date. All fields MUST be of length two
(i.e. 02/07/87 is valid, but 2/7/87 and 02/07/1987
are not valid.)
Return value returns a pointer to the storage location
containing the date structure, or NULL if space
could not be allocated.
See also ddatetolong(), ddatetoshort(), monthexpand(),
strtoddate()
Example #include <datehk.h>
main()
{
struct ddate *today;
char strtoday[9];
strcpy(strtoday,"04/01/67");
if ((today = strtoddate(strtoday) != NULL) {
printf("today is %d-%d-%d\n",
today->dmon, today->dday,
today->dyear);
printf("or %s\n", strtoday);
}
}
Program output today is 4-1-67
or 04/01/67
Page 95
Name strtodol - converts a string to dollar format
Usage char *strtodol(char *source);
Prototype in stringhk.h
Description strtodol converts a string pointed to by source to
dollar format ($-12,839.44). An optional leading
sign is copied. Only the first 2 decimal places
are copied (the string is truncated, not rounded.)
Return value returns a pointer to the storage location
containing the dollar formatted string, or NULL if
space could not be allocated. The returned string
is NOT the same as the string passed to the
function. This function does NOT write over the
string passed to it.
Example #include <stringhk.h>
#include <stdio.h> /* for the printf */
main()
{
char sint[15], *dollar
strcpy(sint,"12839.44");
dollar = strtodol(sint);
printf("%s -> %s\n",sint,dollar);
strcpy(sint,"+62939445.1");
dollar = strtodol(sint);
printf("%s -> %s\n",sint,dollar);
}
Program output 12839.44 -> $12,839.44
+62939445.1 -> $+62,939,445.10
Page 96
Name strtotime - convert a string to a time structure
Usage struct time *strtotime(char *source);
Prototype in timehk.h
Description strtotime converts a string to a time structure,
checking for AM/PM or 24-hour format. If seconds
or hundredths of seconds are not in the string,
their values will be set to 0 in the structure.
Return value returns a pointer to the storage location
containing the time string, or NULL if space could
not be allocated.
See also timetostr()
Example #include <timehk.h>
main()
{
struct time *now;
strcpy(strnow,"5:12 PM");
if ((now = strtotime(strnow)) != NULL)
printf("%d hours, %d min, %d.%d secs\n",
now->ti_hour, now->ti_min,
now->ti_sec, now->ti_hund);
}
Program output 17 hours, 12 min, 0.0 secs
Page 97
Name timetostr - convert time structure to a string
Usage char *timetostr(struct time *tsource, boolean
seconds, boolean hundreds, boolean
ampm);
Prototype in timehk.h
Description timetostr converts a time structure to a string,
with the following options:
seconds = put seconds in string
hundreds = put hundreths of seconds in string
ampm = append AM/PM to string
if ampm is FALSE, 24-hour time will be used.
if hundreds is TRUE, seconds are automatically put
into the string.
Return value returns a pointer to the storage location
containing the time string, or NULL if space could
not be allocated.
See also strtotime()
Example #include <timehk.h>
main()
{
char *strnow;
struct time now;
gettime(&now);
if ((strnow = timetostr(&now, FALSE, TRUE,
TRUE)) != NULL)
printf("The time is %s\n",strnow);
}
Program output The time is 11:23:14.22 PM
Page 98
Name valid_date - check if a date is valid
Usage boolean valid_date(int month, int day, int
yearnum);
Prototype in datehk.h
Description valid_date checks if the given date is valid.
Return value returns TRUE if the date is valid, FALSE
otherwise.
See also isleapyear()
Example #include <datehk.h>
main()
{
int i, d[3] = { 11, 5, 2 }, m[3] = { 31, 12,
29},
y[3] = { 70, 1987, 1981 };
for (i=0; i<3; ++) {
printf("%d/%d/%d ", m[i], d[i], y[i]);
if (valid_date(m[i], d[i], y[i])
printf("valid\n");
else
printf("INVALID\n");
}
}
Program output 11/31/70 INVALID /* Nov has 30 days */
5/13/1987 valid
2/29/1981 INVALID /* 1981 not a leap year */
Page 99
Name vert_line - draw a vertical line
Usage void vert_line(byte c, unsigned int len, byte row,
byte col);
Prototype in video.h
Description draws a vertical line of characters c of length
len beginning at (col,row) via INTerrupts.
vert_line does no error checking on the passed
parameters.
Return value nothing.
See also box(), horiz_line(), restore_box(),
restore_screen(), save_box(), save_screen()
Example #include <video.h>
main()
{
vert_line('*',7,4,4); /* draw 7 *'s at
(4,4) */
}
Page 100
Name wherex - X-coordinate of cursor
Usage byte wherex(void);
Prototype in video.h
Description returns the X-coordinate (column) of the cursor's
current location via INT 0x10, Service 3.
Return value returns the X-coordinate of the cursor's current
location.
See also gotoxy(), read_cursor(), wherey()
Example #include <video.h>
main()
{
printf("Cursor's column = %d\n",wherex());
}
Program output Cursor's column = 12
Page 101
Name wherey - y-coordinate of cursor
Usage byte wherey(void);
Prototype in video.h
Description returns the Y-coordinate (row) of the cursor's
current location via INT 0x10, Service 3.
Return value returns the Y-coordinate of the cursor's current
location.
See also gotoxy(), read_cursor(), wherex()
Example #include <video.h>
main()
{
printf("Cursor's row = %d\n",wherey());
}
Program output Cursor's row = 4
Page 102
#DEFINES
Most of these #defines are self-explanatory. All can be found in
the appropriate header files:
Datehk.h
--------
Date definitions:
typedef enum { Sun, Mon, Tues, Wed, Thrus, Fri, Sat } days;
typedef enum { Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep,
Oct, Nov, Dec } months;
My date structure:
typedef struct ddate {
int dyear; /* Year - 1900 */
int dday; /* Day of month (1-31) */
months dmon; /* Month (Jan = 0) */
};
Note: the year is stored as Year - 1900. For example, if you
wanted to store 1987 in the variable d (of type struct
ddate), you would: d.dyear = 87;
Also note that the months start with zero for January.
Date constants:
#define DATENULL " - - " /* empty date string */
#define DATECHAR '-' /* date delimiter char */
#define DATECHARSTR "-" /* date delim. string */
#define DATECHARTEST "/- " /* all date delimiters */
#define BASE_LEAP_YEAR 1980 /* base year for leap
year calculations */
#define BASE_JUL_YEAR 1720982 /* base day for Julian
Type E calcs */
Filehk.h
--------
File constants:
#define FNAMESIZE 64 /* d:\path\filename.ext =
2 + 49 + 12 + 1 (\0) */
Howard.h
--------
Boolean constants:
#define TRUE 1
#define FALSE 0
Page 103
Ibm.h
-----
Machine id byte:
#define PC 0xFF
#define XT 0xFE
#define Portable_PC 0xFE
#define PCjr 0xFD
#define AT 0xFC
#define Compaq 0x2D
#define Compaq_Plus 0x9A
Memory allocation strategies:
#define MEM_STRAT_FIRST 0 /* use first mem block
large enough */
#define MEM_STRAT_BEST 1 /* use smallest mem block
large enough */
#define MEM_STRAT_LAST 2 /* use high part of last
usable mem block */
#define MEM_STRAT_BADDOS -1 /* using DOS earlier than
3.xx */
Disk id bytes:
#define DISK_DSDD_8 0xFF /* Double-sided, 5 1/4"
floppy, 8 sectors */
#define DISK_SSDD_8 0xFE /* Single-sided, 5 1/4"
floppy, 8 sectors */
#define DISK_SS8_8 0xFE /* Single-sided, 8" floppy,
8 sectors */
#define DISK_DSDD_9 0xFD /* Double-sided, 5 1/4"
floppy, 9 sectors */
#define DISK_SSDD_9 0xFC /* Single-sided floppy,
9 sectors */
#define DISK_DSQD_15 0xF9 /* Double-sided, 5 1/4"
floppy, 15 sectors */
#define DISK_DS3_15 0xF9 /* Double-sided, 3 1/2"
floppy, 9 sectors */
#define DISK_HARD 0xF8 /* Hard disk */
#define DISK_DS3_18 0xF0 /* Double-sided, 3 1/2"
floppy, 18 sectors */
#define DISK_UNDEFINED 0xF0 /* undefined media type */
#define DISK_ERROR 0x0 /* error, try checking
_doserrno */
Note: if the disk is Single-sided, 8" 26 sectors,
it could have the id FE or FD
Page 104
EMS return codes:
#define EMS_ERROR_SOFTWARE 0x80 /* err in EMM software */
#define EMS_ERROR_HARDWARE 0x81 /* malfunction in EM
hardware */
#define EMS_ERROR_UNDEFINED 0x84 /* function requested not
defined */
Math.h
------
Math constants:
#define SQRT2 1.41421356237309504880
#define PI 3.141592653589793238462643
#define E 2.7182818284590452353602874
Math functions:
#define sqr(x) ((x) * (x))
#define sgn(x) ((x) < 0 ? -1 : 1)
#define sign(x) ((x) < 0 ? -1 : 1)
#define swap(x,y) x^=y, y^=x, x^=y
#define max(x,y) ((x) >= (y) ? (x) : (y))
#define min(x,y) ((x) <= (y) ? (x) : (y))
Video.h
-------
Low memory address values:
#define VIDEO 0x10
/* VIDEO INTerrupt service */
#define MODE *((byte far *) 0x449lu)
/* current video mode */
#define PAGE *((byte far *) 0x462lu)
/* current display page */
#define PAGELEN *((unsigned int far *) 0x44Clu)
/* current page length (regen buffer) */
#define VIDOFFSET *((unsigned int far *) 0x44Elu)
/* offset from start of video */
#define ROWCOUNT *((byte far *) 0x484lu)
/* # rows minus 1 on display (EGA,PGA) */
#define CHARHEIGHT *((unsigned int far *) 0x485lu)
/* character height: # bytes/char, # scan lines/char
(EGA,PGA) */
#define CURSOR_UNDERBAR (MODE==7)?0x0B0C:0x0607
/* cursor type: underbar (default) */
#define CURSOR_HALFBLOCK (MODE==7)?0x070C:0x0407
/* cursor type: half-block */
Page 105
VARIABLE TYPES
The following variable types have been defined:
boolean = char Howard.h
byte = unsigned char defined in TC.EXE. See Features.
struct ddate Datehk.h
GLOBAL VARIABLES
These variables are defined for one reason or another and used
internally. None of these variables have to be initialized (see
insertmode.) They are mainly used to return extra values found in
certain functions or needed globally by other functions.
Datehk variables:
Keyboard variables:
boolean key_extended; /* TRUE if special key pressed,
i.e. Alt-X, etc. */
int key_status; /* shift key status byte */
Note: these variables are set by inkey() and getk(), and are
checked by many other keyboard routines.
boolean insertmode; /* insert or overwrite mode? */
Note: This variable is used internally by getstr() and getget().
These functions do NOT initialize this variable. You MUST
set insertmode to TRUE or FALSE before calling either
function or unpredictable results may occur. Upon completion
of this function, testing this variable will determine the
input mode last used. Future versions will default
insertmode to some value if it has not been set.
Video variables:
FRAMES: see video.h for frame[] declarations.
byte char_attribute; /* char attribute for output */
Note: This variable is used by many output functions to set the
attribute byte. For functions such as putstr() you can
either call set_color() with the attribute desired or
declare char_attribute as an extern and then set it
yourself.
Page 106
REVISION HISTORY
Version 0.60 - 1-15-88
------------
Over 30 new functions added:
- Cal...(), Greg...(), Jul...(), fulltoddate(), shorttoddate()
- dayofweek()
- isBREAKon(), setBREAK()
- isVERIFYon(), setVERIFY()
- reboot()
- isExtended(), Extendedtotal(), EMMversion()
- isNetwork()
- memory_strategy()
- disktype()
- set_handles()
- DESQversion(), DESQfreeCPU()
- isDoubleDOS(), DoubleDOSTaskSwitch(), DoubleDOSfreeCPU()
- scrbuff()
- cursor_blink()
- ansi_call()
Fixed a bug in isleapyear(). Previously, isleapyear() would
determine years ending in 00 that were evenly divisible by 4
to be leap years (i.e. 1600). The gregorian calendar (you
know, 30 days hath September...) doesn't count those as leap
years.
Optimized the direct video access routines as well as possible
using 100% C code. Previously they checked for vertical
retrace. Now all direct accesses play with the video
registers and other fun things, basically turning off the
screen for a fraction of a second, performing the access,
then turning the screen back on again. In the longer access
functions (save_screen() to name one) I found changing 30
bytes between screen blankings to be optimal. These changes
have sped up the direct video access functions (putsay(),
save_...(), restore_...()) by a factor or 3! These functions
now take 1/3 the time they used to. If you find the screen
to blink, or that there is snow (putsay() may experience
miniscule snow when outputting long strings) please let me
know and I'll see what I can do.
Version 0.50 - 11-18-87
------------
Initial release of TCHK
Page 107
FUTURE ENHANCEMENTS
There are more functions on the way. If you have any favorites
you would like to see, or need, drop me a line. In future
releases, look for the following features:
- direct screen accesses coded in assembler
- some more video routines
- enhancement of the get and put routines to support all
features found in the @...SAY...GET commands of dBase III+
- enhancement of the put routines to support the 'backslash'
control characters like printf does (\n, \t, etc.)
- more date functions (Julian, Gregorian, and more)
- formats with ease
- some sound functions
- more menu interfaces (popups, Macintosh pulldown menus)
- mouse functions
- more EMS functions
- more hardware id functions (cpu/numeric coprocessor type)
- a general date converter, handling over 40 different date
formats with ease
- a general time converter, handling a dozen different time
- several math functions (integration, numerical methods,+)
- software id functions (TSR, ANSI.SYS, VDISK.SYS, etc.)
If there are some features you would like to see implemented, or
you have any suggestions, comments or questions, please don't
hesitate to contact me. I can be reached at:
Howard Kapustein
1695 Barbara Lane
East Meadow, NY 11554
Phone: (516) 481-9612
or at the following bulletin boards:
The Boss dBBS (201) 568-7293
The Tool Shop (602) 279-2673
Page 108
APPENDIX A - DATE FORMATS
The following date formats are supported by TCHK:
TCHK Reference Date Type Format
-------------- --------- ------
Greg Gregorian (US) MM-DD-YY
GregEuro Gregorian (European) DD-MM-YY
GregJap Gregorian (Japan) YY-MM-DD
Cal Calendar YYMMDD
CalCent Calendar (w/Century) YYYYMMDD
Jul Julian (Type E) special hashed number
JulA Julian (Type A) YYDDD
JulB Julian (Type B) YYYYDDD
full English (Full) Month DD, YYYY
short English (Short) Mon DD, YYYY
ddate struct ddate see datehk.h
- Gregorian units are common shorthand dates (in string format)
with all leading zeros preserved
- Calendar units are numeric representations (double)
- Julian Type E is a special "magic" hashed number (double)
representing the number of elapsed days since an initial date.
Julian Type E numbers are valid for the years 1900-2100 (give
or take a couple of months)
- Julian Type A and B are ANSI defined formats (double)
containing year (and century for type B) and the day of the
year
- full are strings of the date with the full name of the month
- short are strings of the date with the short abbreviation of
the month
- ddate is my own date structure defined in datehk.h
In some instances date formats not specifically designed to hold
the century may overflow. For example, converting CalCent
formatted 20220401 (April 1, 2022) to Greg (MM-DD-YY) would
result in the string "04-01-122". Be aware.
! ! ! WARNING ! ! !
Unless otherwise specified, date format conversion functions
(GregtoCal, JulAtoddate, etc.) do NOT perform error checking. If
you pass an invalid date (March 32, 1988) your result may be have
a slight flaw in it (Gregorian dates) or be totally corrupted.
Julian Type E numbers are valid for the years 1900-2100 (give or
take a couple of months.)
Page 109
Index
A F
Ansi_call 7, 106 Fulltoddate 11, 34, 48, 60,
Atrim 9 106
G
B Getc_match 35, 41, 42, 46,
Box 6, 10, 12, 49, 50
74, 75, 78, 79, Getddate 36
80, 81, 82, 99 Getdouble 37, 40, 43
Getfname 38
C Getget 38, 39, 44, 105
Cal 11, 33, 34, 48, Getint 37, 40, 43
60, 106, 108 Getk 35, 41, 42, 46,
Clear 7, 12, 13, 14 50, 105
Clear_typeahead 13 Getk_match 35, 41, 42, 46,
Cls 7, 12, 14 50
Cursor_blink 15, 16, 17, 18, Getlogical 35, 41, 42, 46,
71, 85, 106 50
Cursor_flip 15, 16, 17, 18, Getreal 37, 40, 43
71, 85 Getstr 39, 44, 105
Cursor_off 15, 16, 17, 18, Getyn 35, 41, 42, 46,
71, 85 50
Cursor_on 15, 16, 17, 18, Gotoxy 7, 38, 47, 68,
71, 85 70, 84, 100, 101
Greg 11, 34, 48, 60,
D 106, 107, 108
Dayofweek 19, 106
Dayofyear 20, 21, 28 H
Daysleft 20, 21, 28 Horiz_line 10, 49, 99
Ddatetolong 22, 23, 24, 67,
94 I
Ddatetoshort 22, 23, 24, 67, Inkey 41, 42, 46, 50,
94 105
Ddatetostr 22, 23, 24, 67 Intlen 51
Delay 25 IsBREAKon 52, 59, 83, 87,
DESQfreeCPU 26, 27, 106 106
DESQversion 26, 27, 106 IsCGA 53
Diffddate 20, 21, 28 IsDoubleDOS 30, 31, 54, 106
Disktype 4, 29, 106 IsEGA 53
DoubleDOSfreeCPU 30, 31, 54, IsEMSavail 32, 33, 55, 56
106 IsExtended 33, 55, 56, 106
DoubleDOSTaskSwitch 30, 31, 54, IsHerc 53
106 Isleapyear 57, 98, 106
IsMDA 53
E IsNetwork 58, 106
EMMversion 32, 55, 106 IsVERIFYon 52, 59, 83, 87,
Extendedtotal 33, 55, 56, 106 106
Page 110
J Save_screen 10, 49, 74, 75,
Jul 11, 19, 34, 48, 78, 79, 80, 99,
60, 102, 106, 106
107, 108 Scrbuff 74, 75, 78, 79,
80, 106
L Scroll_down 81, 82
Leftstr 61 Scroll_up 81, 82
Lotus_setup 63, 66 SetBREAK 52, 59, 83, 87,
Ltrim 9 106
SetVERIFY 52, 59, 83, 87,
M 106
Memory_strategy 64, 106 Set_color 68, 69, 70, 84,
Menu_lotus 63, 65 105
Midstr 61 Set_cursor 15, 16, 17, 18,
Monthexpand 22, 23, 24, 67, 71, 85
94 Set_handles 86, 106
Set_mode 7, 72, 88
P Shorttoddate 11, 34, 48, 60,
Putk 35, 36, 37, 40, 106
43, 44, 68, 69, Strcomma 51, 89
70, 84 Strdel 90
Putsay 68, 69, 70, 106 Strins 91
Putstr 42, 46, 66, 68, Strrep 92
69, 70, 84, 105 Strshleft 93
Strshright 93
R Strtoddate 22, 23, 24, 67,
Read_cursor 15, 16, 17, 18, 94
47, 71, 85, 100, Strtodol 89, 95
101 Strtotime 96, 97
Read_mode 72, 88
Reboot 5, 73, 106 T
Restore_box 10, 49, 74, 75, Timetostr 96, 97
78, 79, 80, 99
Restore_screen 10, 49, 74, 75, V
78, 79, 80, 99 Valid_date 57, 98
Rightstr 61 Vert_line 10, 49, 99
ROM_date 76, 77
ROM_id 76, 77 W
Rtrim 9 Wherex 7, 47, 71, 100,
101
S Wherey 47, 71, 100, 101
Save_box 10, 49, 74, 75, 78, 79, 80, 99